﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Diagnostics;
using System.ComponentModel;
using WPFExcelReport.Helpers;
using System.Windows.Input;
namespace WPFExcelReport
{
    public partial class TAFSWASTAMM
    {
        public TAFSWASTAMM()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWASTAMM();
            this.DataContext = MV;
            InitializeComponent();
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e); 
        } 

        public override void OnDESChg(string des)
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            TMV.WABEZ = des.Trim().PadRight(40);
            base.OnDESChg(des);
        }  
        public override void LOADBYAUF()
        { 
            base.LOADBYAUF();
            if (ORDERNUM.Length < 23)
            {
                return;
            } 
            if (!IsAuto)
                return;
            if (TBMain.Rows.Count > 0)
                return;
            PM["ART"] = ORDERNUM.Substring(1, 20);
            PM["VAR"] = ORDERNUM.Substring(21, 2);
            PM["BEZ"] = DES;
            PM["PROGRP"] = PRODGRP;
            PM["ARTGRP"] = ARTGRP;
            PM["FDDIM"] = DENUM; 
            PM["WABIND"] = "0.00".PadRight(12)+"M  ";
             PM["WAGFKZ"] = "J"; 
            TMV.NEWWS(PM);
            vwMaster.View.MoveCurrentToFirst();
            NewCommand(null, null);
        }
    }
}
